<?                                                                                                                                                                                                                                                                  

if (! ( $MIME_Message = $nntp->get_header($m) ))                                                                                                                                                                                                                                                                  
{                                                                                                                                                                                                                                                                  
    echo "Error on message $m in $nntp_server $breadcrumb";                                                                                                                                                                                                                                                                  
    exit;                                                                                                                                                                                                                                                                  
}                                                                                                        
# print_r ($_POST);                                                  

$header  = $MIME_Message->get_main_header();                                                                                                                                                                                                                                                                    
$subject = $header["subject"];                                                                                                                                                                                                                                                                        
$source  = $_GET["source"];                                                                                                                                                                                                                                                                      
$bilder  = $_GET["k"];                                                                                                                                                                                                                                                      
$fn_test = preg_match("/(\w+).(jpeg|jpg|gif|png)/i",$subject,$image_fn);                                                                                                                                       
$nzb     = multifile_lookup ($subject, $nntp, true) ;                                                                                                                                                                                                                                                                         


if (isset ($_POST["xnzb"]) || isset ($_POST["cnzb"]))                                                                                                       
{                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                            
    echo "<html>";                                                                                                                                                                                                                                                                  
    echo "<title>" . $image_fn[0] . " - " . $subject . "</title>";                                                
    echo "<style>body,td,select,input {font:8pt tahoma}                                                                    
             .dh {border-bottom:solid 1px silver;border-top:solid 1px white;                                                                    
                border-left:solid 1px white;border-right:solid 1px silver;width:100%}                                                                    
             .hp {width:100px;height:10px;border:solid 1px black}                                                                    
             </style>";                                            
                                                                                                
    $cached_nzb_data      = $_POST["cnzb"];                                                                                                    
    $encoded_nzb_data     = $_POST["enzb"];                                                                                                    
    $nzb_title_data       = $_POST["nnzb"];                                                                                                    
    $waiting_for_encode   = $_POST["xnzb"];                                                                                                    
    $old_title_data       = isset ($_POST["onzb"]) ? $_POST["onzb"] : array();                                                                                                    
    $already_did_encode   = isset ($_POST["dnzb"]) ? $_POST["dnzb"] : array();                                                   
    $waiting_for_encode   = array_reverse($waiting_for_encode);                                                                                               
    $nzb_title_data       = array_reverse($nzb_title_data);                                                                                               
    $message_to_encode    = array_pop ($waiting_for_encode);                                                                                                    
    $message_title        = array_pop ($nzb_title_data );                                                                                                    
    $waiting_for_encode   = array_reverse($waiting_for_encode);                                                                                               
    $nzb_title_data       = array_reverse($nzb_title_data);                                                                                               
    $old_title_data[]     = $message_title;                                                                                                   
    $already_did_encode[] = $message_to_encode;                                                                                                   
    echo "<form id='nzbform' method='post' action='$href?$qs'>";                                                                                                   
                                                     
    $html = '<table> <tr> <td> <img src="images/msdn.jpg"> </td>                                                               
               <td nowrap> <table> <tr> <td nowrap id="td_search_options">';                                                                
    $html .= "Searching for ";                                                                            
    $html .= '</td> </tr> <tr> <td nowrap id="td_search_panel"> ';                                                                 
    $html .= '<input size="50" name=nzb_replace value="' . htmlentities( $message_title ) . '">';                                                                                
    $html .= "<input type='submit' value='Download NZB' disabled id=nzbdl>";                                                                
    # $html .= "<input type='submit' value='Retry'  name=nzbretry id=nzbretry>";                                                                
    $html .= '</td> </tr> </table> </td> <td id="td_status_panel"> </td> </tr> </table>';                                                                
    $html .= '<br><div style="width:100%;border-top:solid 1px #339999;background-color:#CCFFCC;padding:3px">';                                                                
    $html .= '<table width="100%" cellpadding="1" cellspacing="1">                                                               
               <tr> <td> <div id="dpages" style="font:9pt arial">Searching for matching posts. Please wait...</div></td></tr></table></div>';                                          
                                                                 
    echo $html . "<table align=center cellpadding=1 cellspacing=1>";                                                                            
    $i=0;                                                                                                     
                                                                                                  
    for ($e=0;$e<count($already_did_encode);$e++)                                                                                                   
    {                                                                
        $enc = $already_did_encode[$e];                                                                                                 
        if (strlen(trim($enc)) > 0)                                                                                                   
        {                                                                           
            echo "<tr bgcolor='" . ($e==count($already_did_encode)-1 ? "white" : "#e0ffe0") . "'>";                                                                         
            echo "<td valign='top' nowrap><input name='dnzb[]' type='checkbox' checked value='$enc'></td>";                                                                                                   
            echo "<td valign='top' nowrap>$enc </td>";                                                                                                   
            echo "<td valign='top' nowrap><div class='hp'><img src='images/progress.gif' id='ix_" . $enc . "' width='" . ($e==count($already_did_encode)-1 ? "1" : "100") . "' height='10'></div></td>";                                                                                                   
            echo "<td valign='top' nowrap>" . qtrim($old_title_data[$e]) . "</td>";                                                                                                   
            echo "<td valign='top' nowrap><input name='onzb[]' type='hidden' value=\"" . qtrim($old_title_data[$e]) . "\"></td>";                                                                                                   
            echo "</tr>";                                                                         
            $i++;                                                                                                    
        }                                                                                                  
                                                                                                           
    }                                                                              
                                                                                                   

    for ($e=0;$e<count($waiting_for_encode);$e++)                                                                                                   
    {                                                                                                   

        $enc = $waiting_for_encode[$e];                                                                                                 
        if (strlen(trim($enc)) > 0)                                                                                                   
        {                                                    
            echo "<tr bgcolor=mistyrose>";                                                                         
            echo "<td valign='top' nowrap><input name='xnzb[]' type='checkbox' checked value='$enc'></td>";                                                                                                   
            echo "<td valign='top' nowrap>$enc </td>";                                                                                                   
            echo "<td valign='top' nowrap><div class='hp'><img src='images/progress.gif' width='1' height='10'></div></td>";                                                                                                   
            echo "<td valign='top' nowrap><b>" . qtrim($nzb_title_data[$e]) . "</b> </td>";                                                                                                   
            echo "<td valign='top' nowrap><input name='nnzb[]' type='hidden' value=\"" . qtrim($nzb_title_data[$e]) . "\"></td>";                                                                                                   
            echo "</tr>";                                                                         
            $i++;                                                                                                 
        }                                                                                                                       
    }                                            

    echo "</table>";                                      
                                                                           
    echo "<center><img height='16' src='image.php?p=" . floor (600 * ((count($already_did_encode)-1) / $i)) . "&w=600&h=16'><center><br>";                                                                                                               
                                                                                                          
                                                                                                                  
    if (strlen($message_to_encode) > 0)                                                                                             
    {                                                                                             
        echo "<textarea name='cnzb' style='display:none'>";                                                                                                
        echo stripslashes($encoded_nzb_data);                                                                                                          
        echo stripslashes($cached_nzb_data);                                                                                                          
        echo "</textarea>";                                                                                      

       # echo "<hr>";                                                                                            

        $MIME_Message = $nntp->get_header($message_to_encode);                                                                                                                                                 
        $header = $MIME_Message->get_main_header();                                                                                                                                                                                                                                                                      
        $subject = $header["subject"];                                                                                         
        echo "Looking up $subject... <br>";                                                                                                                                            
        $nzb = nzb_create($nntp, $MIME_Message, false);                                                                                      
        echo "Done!";                                                                                                
        echo "<textarea name='enzb' style='display:none'>";                                                                                                
        echo $nzb; # htmlentities ($nzb);                                                                                                          
        echo "</textarea>";                                                                                                  
    }                                                                                               
    else                                                                                         
    {                                                                                          
         preg_match("/([\-a-zA-Z()\s\d]*\.\w{3})/", $header["subject"], $tmp);                                                                                                                              
         $gnzb = create_nzb_header();                                                                                                                             
         $gnzb .= stripslashes($encoded_nzb_data);                                                                                                                             
         $gnzb .= stripslashes($cached_nzb_data);                                                                                                                             
         $gnzb .= "</nzb>";                                                                                       
                                                                                                                         
         print "Process complete!<input type='hidden' name='dlname' value='msgid_".$m."_".$tmp[1].".nzb'><textarea style='display:none' name='dlnzb'>";                                                                                                                              
         print $gnzb; # htmlentities( $gnzb );                                                                                                                             
         print "</textarea>";                                                                                
         echo script_block ("document.all('nzbdl').disabled=false;");                                         
         # echo "<br><input type=submit value='Download NZB File'>";                                                                                   
                                                                                                    
    }                                                                                               

                                                                                                                 
    echo "</form>";                                                                                                   
                                                                                                                 
                                                                                                                           
    echo script_block ("document.all('nzbform').submit();");                                                                                             

                                                                                                        
    exit;                                                                                                        
}                                                                                                        
         # 'width:100%;background-color:ivory;border-bottom:solid 1px gray;font:8pt tahoma;color:navy;padding:2px;margin-bottom:2px                          

                                                                                                                                                                                                                                                
if ($source=="object")                                                                                                                                                                                                                                                                  
{                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                            
    echo "<html>";                                                                                                                                                                                                                                                                  
    echo "<title>" . $image_fn[0] . " - " . $subject . "</title>";                                                                                                                                                                                                                                                                  
    # echo "<link href='style.css' rel='stylesheet' type='text/css' />";                           
    echo "<link rel='stylesheet' href='style.css' type='text/css' title='Default'/>";                                  
    echo "<link rel='alternate stylesheet' href='pretty.css' type='text/css' title='Pretty'>";                          
    echo "<link rel='alternate stylesheet' href='orange.css' type='text/css' title='Orange'>";                                                                                                                                                                                                                                                               
    echo "<link rel='alternate stylesheet' href='white.css' type='text/css' title='White'>";                                                                                                                                                                                                                                                               
    echo "<" . "script src='scripts/slides.js'></"."script>\n";                                                                                                                                                                                                                                                              
    echo "<" . "script src='scripts/global.js'></"."script>\n";                                                                                                                                                                                                                                                              
    echo "<" . "script src='http://www.101stratford.com/pimp/xmlextras.js'></"."script>\n";                                                                                                                                                                                                                                                               
    echo "<body topmargin=0 onload='desktop_background_resize();' leftmargin=0 rightmargin=0>";                          
    echo "<div class='headeralert' style='margin-bottom:2px'>   ";                                                                                                                                                                                                      
    echo "<img src='image.php?i=error' align=absmiddle><span id='dupdate'>    ";                                                                                                                                                                                                     
    echo "Loading...</span>     ";                                                                                                                                                                                                     
    echo "</div>             ";                                                                                                                             
   echo script_block ("var APP_NAME='" . APPLICATION_NAME . "';REGEX_MASK_PICTURE=" . REGEX_MASK_PICTURE . "");
    echo "<table width='100%' class='bevel3' cellpadding='1' cellspacing='1'>";   // --> 1                                                                                                                                                                 
    echo "<tr>";                                                                                                                                                                                      
    echo "<td>";                                                                                                                                                                                      
    echo " <div style='margin:3px' id='nzbcontainer'>";                                                                                                                                                                                                                                         
   #  echo '  &nbsp;&nbsp;<a href="javascript:arr.mark()" class="button"><img border="0" align="absmiddle" src="images/pano-nudger.png" onclick="arr.mark()">Bookmark</a>';                                                                                                                                                                                                                                                                            
   # echo " &nbsp;<a href='javascript:arr.find()'>Find all</a>";                                                                                                                                                                                       
    echo "</div></td>";                                                                                                                                                                                                         
                                                                                                                                                                                                                                                      
    echo "<td nowrap>";                                                                                                                                                                                                                                  
    echo " File:<select id='sltaddy' onchange='window.create_preview(sltaddy.selectedIndex)'></select>";                                                                                                                                                                                       
    echo "<span id='infospan'></span>";                                                                                                                                                                                                
    echo "</td>";                                                                                                                                                                                      
                                                                                                                                                                                     
    # nav controls                                                                                                                                                                                                                                                      
    echo "<td align='right'>";                                                                                                                                                                                                    
                                                                                                                                                                                                      
    echo '<a class="prev" href="javascript:arr.advance(-1)"><i class="spacer">Prev</i></a>';                                                                                                                                                                                                                                                                            
    echo '<a class="stopped" id="astop" href="#" onclick="arr.state=0"><i class="spacer">Stop</i></a>';                                                                                                                                                                                                                                                                            
    echo '<a class="play" id="aplay" href="#" onclick="arr.state=1;arr.advance(1)"><i class="spacer">Play</i></a>';                                                                                                                                                                                                                                                                            
    echo '<a class="next" href="javascript:arr.advance(1)"><i class="spacer">Next</i></a>';                                                                                                                                                                                                      
                                                                                                                                                                                                                                              
    echo "</td>";                                                                                                                                                                                       
    echo "</tr>";                                                                                                                                                                                   

    echo "<tr>";                                                                                                                                                                                       
    echo "<td colspan='3'>";                                                                                                                                                                                                       
                                                                                                                                                                                                                                                           
    echo "<table width=100% cellpadding='0' cellspacing='0'><tr><td valign='top' align='center'>"; // --> 2                                                                                                                                                                                                      
                                                                                                                                                                                                                                                          
    echo "<table width=100% class='bevel4' cellpadding='1' cellspacing='1'>";     // --> 3                                                                                                                                                                                        
    echo "<tr><td align='center'>";                                                                                                                                                                                                                                                       
    echo "  <div style='height:100px;filter:progid:DXImageTransform.Microsoft.Fade();cursor:hand' onclick='arr.mark()' class=resizeXZ id='dpreview'>";                                                                                                                                                                                                                                                            
    echo "    <img id='iinfo' src='/webservices/images/clear.gif'>";                                                                                                                                                                                                                                                            
    echo "  </div>";                                                                                                                                                                                                                                                            
    echo "</td>";                                                                                                                                                                                       
    echo "</tr>";                                                                                                                                                                                       
    echo "</table>";    // 3 <--                                                                                                                                                                                                   

    # subject name container                                                                                                                                                                                                                                                             
    echo "    <div id='dsubj' style='color:gray'></div>";                                                                                                                                                                                                                                                            
    echo "    <div id='dcont'>";                                                                                                                                                                                                         
                                                                                                                                                                                                                                                      
    echo "    </div>";                                                                                                                                                                                                        
                                                                                                                                                                                                                                                        
    echo "</td></tr>";                                                                                                                                                                                       
    echo "</table>";   // 2 <--                                                                                                                                                                                                    
                                                                                                                                                                                                                                                              
    echo "</td></tr>";                                                                                                                                                                                       
    echo "</table>\n";     // 1 <--                                                                                                                                                                                                                                                            
    echo "<" . "script>\n";                                                                                                                                                                                                                                                                        
    echo "var TransformType='RandomBars';";                                                                                                                                                                      
    echo "var states=new Array('Stopped','Playing...');";                                                                                                                                                                                                                                                                         
    echo "var NNTP='$nntp_server';";                                                                                                                                                                                                                                                                         
    echo "var d=MM_findObj;";                                                                                                                                                                                                                                                                         
    echo "var arr=new slideshow();";                                                                                                                                                                                                                                                                          
    echo "arr.container='dpreview';";     /*  */                                                                                                                                                                                                                                                                                                       
    echo "arr.add ('$m', \"" . htmlentities(trim($image_fn[0])) . "\", \"" . htmlentities(trim($subject)) . "\");";                                                                                                                                                                                                                                                                  
    echo "arr.draw=show_single_image;";                                                                                                                                                                                                                                                       
   # echo "arr.state=0;";                                                                                                                                                                                                                                                       
    echo "arr.current='iinfo';";                                                                                                                                                                                                                                                       
    echo "arr.ispicture=" . ($fn_test?"true":"false") . ";";                                                                                                                                                                                                                                                       
    echo "arr.group='" . get_request("art_group") . "';";                                                                                                                                                                                                                                                 
    echo "arr.loaded = function ()                                                                                                                                                                                                                                                
    {                                                                                                                                                                                                                                                
        d('dsubj').innerHTML = this.slides[this.index]._subject;                                                                                                                                                                                                                                              
        d('dpreview').style.filter = 'progid:DXImageTransform.Microsoft.' + TransformType + '()';                                                                                                                                                                                                                                                              
        desktop_background_resize();                                                                                                                                                                                                
        if (arr.state==1)                                                                                                                                                                                                                                                              
        {                                                                                                                                                                                                                                                              
            arr.timer = setTimeout ('arr.advance(1)', 5000);                                                                                                                                                                                 
                                                                                                                                                                                                                                                                     
        }                                                                                                                              
        play_css_filter(this.container);                                                                                                                                 
        hi_lite(this.index);                                                                                                                                         
        d('infospan').innerHTML = '&nbsp;&nbsp;' + (1+this.index) + ' of ' + this.slides.length + '&nbsp;[' + states[this.state] + ']';                                                                                                                                                                                            
    }\n";                                                                                                                                                                                                                                               
    echo "arr.loading = function ()                                                                                                                                                                                                                                                
    {                                                                                                                                                                                                                                                
        window.status = 'Loading ' + this.slides[this.index]._subject + '...';                                                                                                                                                                                                                                              
    }\n";                                                                                                                                                                                                                                               
    echo "var html=arr.list('A$m');";                                                                                                                                                                                                                                                             
    #echo "var enc='<form method=post action=\"$href?$qs\">';";                                                                                                                                                                                                                                                             
    #echo "for (var x=0;x<arr.slides.length;x++) { if (arr.slides[x]._name && arr.slides[x]._name!='') { \n  ";                                                                                                                                                                                                                                                             
    #echo "enc+='<input type=hidden name=xnzb[] value=\"' + arr.slides[x]._id + '\">';  ";                                                                                                                                                                                                                                                             
    #echo "enc+='<input type=hidden name=nnzb[] value=\"' + arr.slides[x]._name + '\">'; } \n } \n ";                                                                                                                                                                                                                                                             
    #echo "enc+='<input type=submit value=Export All>';";                                                                                                                                                                                                                                                             
    #echo "enc+='</form>'; d('nzbcontainer').innerHTML = enc;";                                                                                                                                                                                                                                                             
    echo "window.create_preview(0);";                                                                                                                            
    echo "var msg = '&nbsp;' + arr.slides.length + \" articles like '". htmlentities( trim( mid_str($subject,40) ) ) ."'.  \" ;";                                                                                                                                                                                                                                                     
    echo "msg += '<a style=color:blue href=\"javascript:arr.find()\">Search for articles like this</a>&nbsp;&nbsp;';";                                                                                                                                                                                                                                                     
    echo "msg += '<a style=color:blue href=\"javascript:arr.mark()\">Bookmark</a>&nbsp;&nbsp;';";                                                                                                                                                                                                                                                     
    echo "msg += '<a style=color:blue href=\"javascript:arr.mail()\">Send to a friend</a>';";                                                                                                                                                                                                                                                     
    echo "d('dupdate').innerHTML = msg ;\n";                                                                                                                                                                                                                                                     
    echo "</"."script>\n";                                                                                                                                                                                                                                                              
    echo "</"."body>\n";                                                                                                                                                                                                                                                              
    echo "</"."html>\n";                                                                                                                                                                                                                                                              
    exit;                                                                                                                                                                                                                                                              
}                                                                                                                                                                                                                                                                  
else                                                                                                                                                                                                                                                                  
{                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                       
    if ($nzb["count"]>0)                                                                                                                                                                                                                                                                  
    {                                                                                                                                                                                                                                                                    
        $make_param = $nzb["name"];                                                                                                                                                                                                                                                                   
       # print $make_param . "<br>";                                                                                                                                                                                                                                                                  
    }                                                                                                                                                                                                                                                                  
    else                                                                                                                                                                                                                                                                  
    {                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                            
    }                                                                                                                                                                                                                                                                  
    $make_param = preg_replace ("/([\-,\.\s|\d|\]|\[|_])/", "*", $subject);                                                                                                                                                                                                                                                                  
    $v="";                                                                                                                                                                                                                                                                  
    $b=true;                                                                                                                                                                                                                                                                  
    for ($k=0;$k<strlen($make_param);$k++)                                                                                                                                                                                                                                                                  
    {                                                                                                                                                                                                                                                                  
        $c=substr($make_param,$k,1);                                                                                                                                                                                                                                                                  
        if ($c=="*")                                                                                                                                                                                                                                                                  
        {                                                                                                                                                                                                                                                                  
           if ($b)                                                                                                                                                                                                                                                                  
           {                                                                                                                                                                                                                                                                  
               $v .= "*";                                                                                                                                                                                                                                                                  
               $b  = false;                                                                                                                                                                                                                                                                  
           }                                                                                                                                                                                                                                                                   
        }                                                                                                                                                                                                                                                                  
        else                                                                                                                                                                                                                                                                   
        {                                                                                                                                                                                                                                                                  
            $v .= $c;                                                                                                                                                                                                                                                                  
            $b  = true;                                                                                                                                                                                                                                                                  
        }                                                                                                                                                                                                                                                                   
    }                                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                      
    # print $make_param;                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                      
    $list = $nntp->search_newsgroup (1, $make_param, "subject" ,false,false,false);                                                                                                                                                                                                                                                                  
    $list = $list["articles"];                                                                                                                                                                                                                                                                   
    $ret = array();                                                                                                                                                                                                                                                                  
    $srt = array();                                                                                                                                                                                                                                                                  
    $cnt = 0;                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                      
    foreach ($list as $item)                                                                                                                                                                                                                                                                  
    {                                                                                                                                                                                                                                                                  
        $ok=true;                                                                                                                                                                                                                                                                  
        $reg_tmp = preg_match("/[(](\d+)\/(\d+)[)]/", $item->subject, $tmp);                                                                                                                                                                                                                                                                   
        if ($reg_tmp)                                                                                                                                                                                                                                                                  
        {                                                                                                                                                                                                                                                                  
           $idx = $tmp[1];                                                                                                                                                                                                                                                                  
           if ($idx!=1)                                                                                                                                                                                                                                                                  
           {                                                                                                                                                                                                                                                                  
              $ok=false;                                                                                                                                                                                                                                                                  
           }                                                                                                                                                                                                                                                                  
        }                                                                                                                                                                                                                                                                  
        if ($ok)                                                                                                                                                                                                                                                                  
        {                                                                                                                                                                                                                                                                  
           $ret[$item->subject] = $item->nntp_message_id;                                                                                                                                                                                                                                                                  
           $srt[] = $item->subject;                                                                                                                                                                                                                                                                  
           $cnt ++;                                                                                                                                                                                                                                                                  
        }                                                                                                                                                                                                                                                                  
    }                                                                                                                                                                                                                                                                  
    sort ($srt);                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                      
    $unq_arr  = array();                                                                                                                                                                                                                                                                         
    $item_arr = array();                                                                                                                                                                                                                                                                  
    foreach ($srt as $item)                                                                                                                                                                                                                                                                  
    {                                                                                                                                                                                                                                                                  
        $fn_test = preg_match('/["]*(\S+).(jpeg|jpg|gif|png)/i', $item, $image_fn);                                                                                                                                                                                                                                                                   
        if ($fn_test)                                                                                                                                                                                                                                                                  
        {                                                                                                                                                                                                                                                                  
            $name = $image_fn[0];                                                                                                                                                                                                                                                                  
            if (array_search($name, $unq_arr)===false)                                                                                                                                                                                                                                                                  
            {                                                                                                                                                                                                                                                                  
                $item_arr[] = array ("id"=>$ret[$item],                                                                                                                                                                                                                                                                  
                                     "name"=>htmlentities(trim($name)),                                                                                                                                                                                                                                                                  
                                     "subject"=>htmlentities(trim($item))                                                                                                                                                                                                                                                                  
                                     );                                                                                                                                                                                                                                                                   
            }                                                                                                                                                                                                                                                                  
            $unq_arr[] = $name;                                                                                                                                                                                                                                                                  
        }                                                                                                                                                                                                                                                                   
    }                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                      
    $fn_test = preg_match("/(\w+).(jpeg|jpg|gif|png)/i",$subject,$image_fn);                                                                                                                                                                                                                                                                   

}                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                     
$filters = explode("\n", "Fade                                                                                                                                                                                                                                                                   
                          Barn                                                                                                                                                                                                                                                                   
                          Blinds                                                                                                                                                                                                                                                                   
                          CheckerBoard                                                                                                                                                                                                                                                                   
                          GradientWipe                                                                                                                                                                                                                                                                   
                          Inset                                                                                                                                                                                                                                                                   
                          Iris                                                                                                                                                                                                                                                                   
                          Pixelate                                                                                                                                                                                                                                                                    
                          RadialWipe                                                                                                                                                                                                                                                                    
                          RandomBars                                                                                                                                                                                                                                                                   
                          RandomDissolve                                                                                                                                                                                                                                                                   
                          Slide                                                                                                                                                                                                                                                                   
                          Spiral                                                                                                                                                                                                                                                                   
                          Stretch                                                                                                                                                                                                                                                                   
                          Strips                                                                                                                                                                                                                                                                    
                          Wheel                                                                                                                                                                                                                                                                   
                          Zigzag");                                                                                                                                                              

# BEGIN HTML                                                                                                                                                                                                                                                               
# =================================================================                                                                                                                                                                                                                                                               
echo "<html>";                                                                                                                                                                                                                                                                  
echo "<title>" . $image_fn[0] . " - ".$subject."</title>";                                                                                                                                                                                                                                                                  
echo "<link rel='stylesheet' href='style.css' type='text/css' title='Default'/>";                                  
echo "<link rel='alternate stylesheet' href='pretty.css' type='text/css' title='Pretty'>";                          
echo "<link rel='alternate stylesheet' href='orange.css' type='text/css' title='Orange'>";                                                                                                                                                                                                                                                            
echo "<link rel='alternate stylesheet' href='white.css' type='text/css' title='White'>";                                            
   echo script_block ("var APP_NAME='" . APPLICATION_NAME . "';REGEX_MASK_PICTURE=" . REGEX_MASK_PICTURE . "");                                                                                                                                                                                                                                                          
echo "<body topmargin='2' leftmargin='2' rightmargin='2' background='/editor.php?i=b'";                                                                                                                                                                                                                                                             
echo " bgcolor='#f0f0f0' style='border:solid 1px #f0f0f0'>";                                                                                                                                                                                                                                                                   
echo "<table width='100%' class='bevel3' cellpadding='1' align='center' cellspacing='1'>";   // --> 1  ***                                                                                                                                                              
echo "<tr>";                                                                                                                                                                                      
echo "<td align='center'>";                                                                                                                                                                                      
echo "<div style='padding:3px' id='dx'>";                                                                                                                                                                                      
echo "<table width='100%' cellpadding='0' cellspacing='0'><tr><td>";   // --> 2                                                                                                                                                                                       
echo "<div style='padding:3px' id='dx'>";                                                                                                                                                                                    
echo "<table width='100%' cellpadding='0' cellspacing='0'><tr><td>";                     
echo "File: <select id='sltaddy' onchange='arr.set_index(sltaddy.selectedIndex)'>";                                                                                                                                                          
                                                                                                                                                                                                                                                                  
$index = 0;                                                                                                                                                                                                                                                                  
$selected_index = 0;                                                                                                                                                                                                                                                                  
foreach ($item_arr as $item)                                                                                                                                                                                                                                                                  
{                                                                                                                                                                                                                                                                    
    $name_str = $item["name"];                                                                                                                                                                                                                                                                  
    $name_str = str_replace("&quot;","",$name_str);                                                                                                                                                                                                                                                                  
    if ($item["id"]==$m)                                                                                                                                                                                                                                                                  
    {                                                                                                                                                                                                                                                                  
         print "<option selected value='".$item["id"]."' style='font:bold;color:blue'>" . $name_str;                                                                                                                                                                                                                                                                   
         $selected_index = $index;                                                                                                                                                                                                                                                                  
    }                                                                                                                                                                                                                                                                  
    else                                                                                                                                                                                                                                                                  
    {                                                                                                                                                                                                                                                                  
         print "<option value='".$item["id"]."'>" . $name_str;                                                                                                                                                                                                                                                                   
    }                                                                                                                                                                                                                                                                  
    $index ++;                                                                                                                                                                                                                                                                  
}                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                      
echo "</select> ";                                                                                                                                                                                      
echo "&nbsp;&nbsp;";                                                                                                                                                          
echo "<span id='iidx'>" . $cnt . "</span> ";                                                                                                                                                                                      
echo " of ";                                                                                                                                                                                      
echo "<span id='saddy'>" . $cnt . "</span>   ";                                                                                                                                                       
echo "&nbsp;&nbsp; ";                                                                                                                                
echo "<select id='ispd' name='ispd'><option value='1'>Fast<option value='5' selected>Medium<option value='25'>Slow</select>";                                                                                                                                                        
echo "<input size=2 id='iwdt' name='iwdt' type=hidden value='500'>";                                                                                                                                                             
echo "";                                                                                                                                                             
echo "&nbsp;&nbsp;";                                                                                                                                                             
echo 'Transition <select id=dtrans>';                                                                                                                          
foreach ($filters as $filter)                                                                                                                                                       
{                                                                                                                                                       
    echo "<option value='" . trim($filter) . "'>" . trim($filter);                                                                                                                                                       
}                                                                                                                                                       
echo '</select>';                                                                                                                                                             
echo " </div>   ";                                                                                                                           
echo "</td><td align='right'>";                          
echo '<a class="prev" href="javascript:arr.advance(-1)"><i class="spacer">Prev</i></a>';                                                                                                                                                                                                                                                                            
echo '<a class="stopped" id="astop" href="#" onclick="arr.state=0"><i class="spacer">Stop</i></a>';                                                                                                                                                                                                                                                                            
echo '<a class="play" id="aplay" href="#" onclick="arr.state=1;arr.advance(1)"><i class="spacer">Play</i></a>';                                                                                                                                                                                                                                                                            
echo '<a class="next" href="javascript:arr.advance(1)"><i class="spacer">Next</i></a>';                                                                                                                  
echo "&nbsp;</td></tr></table> ";                     

echo "<table width='99%' border='0' align='center' class='bevel4'><tr>";                                                                                                                                                        
echo "<td align=center><table><tr><td><img id=pinfo src='images/i_animated_loading_32_2.gif'></td><td>";                                                                                                                                                                  
echo "<div id='dpreview' style='height:322;filter:progid:DXImageTransform.Microsoft.Fade();'><img id=iinfo src='images/i_animated_loading_32_2.gif'></div>";                                                                                                                                                                  
echo "</td><td><img id=ninfo src='images/i_animated_loading_32_2.gif'></td></tr></table>";                                                                                                         
echo "<span style='font:7pt tahoma;color:gray' id=dsubj></span>&nbsp;&nbsp;";                                                                                                         
echo "<a class='normal' href='javascript:arr.mark()'>Bookmark</a>&nbsp;&nbsp;";                                                                                                          
echo "<a class='normal' href='javascript:arr.mail()'>Send to a friend</a>";                                                                                                 
echo "</td></tr></table>\n";                        
                                                                                                                                                     
# BEGIN SCRIPTS                                                                                                                                                      
# =================================================================                                                                                                                                                      
echo "<" . "script src='scripts/slides.js'></"."script>                                                                                                                                                       
      <" . "script src='scripts/global.js'></"."script> ";                                                                                                                                                      
echo "<" . "script language='javascript'>                                                                                                                      
                                                                                                                                          
var speed = 5000;                                                                                                                                                   
function MM_findObj(n, d) { //v4.01                                                                                                                                                   
    var p,i,x;  if(!d) d=document; if((p=n.indexOf('?'))>0&&parent.frames.length) {                                                                                                                                                   
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}                                                                                                                                                   
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];                                                                                                                                                   
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);                                                                                                                                                   
    if(!x && d.getElementById) x=d.getElementById(n); return x;                                                                                                                                                   
}                                                                                                                                                    
// alert (1);                                                                                                                                                    
var idx=0,tm=null;                                                                                                                                                    
var arr=new slideshow();                                                                                                                                                   
arr.container   = 'dpreview';                                                                                                                                                   
arr.current     = 'iinfo';                                                                                                                                                   
arr.previous    = 'pinfo';                                                                                                                                                   
arr.next        = 'ninfo';                                                                                                                                                    
arr.index       = ".$selected_index.";                                                                                                                                                   
arr.group       = '" . get_request("art_group") . "';                                                                                                                                                   
arr.loaded = function ()                                                                                                                                                   
{        er=0;                                                                                                                                       
    try                   
    {                                                                                                                      
        var d=MM_findObj;                                                                                                                                                    
        d('iwdt').value            = DH-80;  er=1;                                                                                                                                                  
      //  d('ips').value             = 'Pause';  er=2;                                                                                                                                                    
        d('saddy').innerHTML       = arr.slides.length;  er=3;                                                                                                                                                    
      //  d('bks').disabled          = true;  er=4;                                                                                                                                                    
        d('iidx').innerHTML        = arr.index + 1;  er=5;                                                                                                                                                   
        d('sltaddy').selectedIndex = arr.index;  er=6;                                                                                                                                                   
        d('dsubj').innerHTML       = arr.slides[arr.index]._subject + ' - ' + arr.slides[arr.index]._w + ' x ' + arr.slides[arr.index]._h;  er=7;                                                                                                                                                   
      //  d('bks').disabled          = false;   er=8;                                                                                                                                                    
        d('dpreview').style.height = d('iwdt').value - 2;  er=9;                                                                                                                                                   
        d('dpreview').style.filter = 'progid:DXImageTransform.Microsoft.' + d('dtrans').value + '()';   er=10;                                                                                                                                                  
    } catch (ex) { alert (er+'. '+ex.message); }                                                                                                                                               
    if (arr.state==1)                                                                                                                                                   
    {                                                                                                                                                   
         arr.timer = setTimeout ('arr.advance(1)', d('ispd').value * 1000);                                                                                                                                                    
    }                                                                                                                                                    
    nav_correct(arr.state);                  
}                                                                                                                                                   
function bk()                                                                                                                                                    
{                                                                                                                                                    
    window.open('skin.php?message_id='+arr.slides[arr.index]._id+'&art_group=" . get_request("art_group") . "&a=bookmark', '', 'width=200,height=240,statusbar=no');                                                                                                                                                    
}                                                                                                                                                   
    ";                                                                                                                                                   
                                                                                                                                                    
foreach ($item_arr as $item)                                                                                                                                                   
{                                                                                                                                                    
    print "arr.add (\"" . $item["id"] . "\", \""                                                                                                                                                    
                        . $item["name"] . "\", \""                                                                                                                                                    
                        . $item["subject"] . "\") ;";                                                                                                                                                   
}                                                                                                                                                   
                                                                                                                                                           
                                                                                                                                                           
if ($source=="object")                                                                                                                                                   
{                                                                                                                                                   
    print "var lst=opener.window.groups['A$m'];                                                                                                                                                   
    for (e=0;e<lst.length;e++)                                                                                                                                                    
    {                                                                                                                                                   
       arr.add (lst[e]._id,lst[e]._title,lst[e]._name);                                                                                                                                                   
       var opt=new Option()                                                                                                                                                   
       opt.text=lst[e]._title;                                                                                                                                                   
       opt.value=lst[e]._id;                                                                                                                                                   
       sltaddy.options.add (opt);                                                                                                                                                   
    }";                                                                                                                                                   
}                                                                                                                                                   
print "arr.draw();                                                                                                                                                             
</" . "script>";                                                                                                                                                       
print "</" . "body>";                                                                                                                                                       
?>